package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.exception.CustomException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class DemoController {

//  http://localhost:8080/hello
    @GetMapping("/hello")
    public Result hello(){
        int a = 1 / 0;
        return Result.success(10);
    }

    @GetMapping("/count")
    public Result count(){
        throw new CustomException("400","错误，禁止访问");
    }

    @GetMapping("/map")
    public Result map(){
        Map<String, Object> map = new HashMap<>();
        map.put("name","UNK");
        map.put("age",18);
        return Result.success(map);
    }

}
